<script setup>
import { onMounted } from "vue"
import { getBase } from "@/api";
import { useI18n } from 'vue-i18n'
const { locale } = useI18n();
onMounted(() => {
  init()
})
const init = () => {
  getBase().then(res => {

    const lang = res.site?.language || 'en-us';
    const arr = lang?.split('-');
    if (!localStorage.getItem('language')) {
      locale.value = arr[0];
      localStorage.setItem('language', arr[0]);
    }
    const language = localStorage.getItem('language') || arr[0];
    document.title = res.site[`siteName${language.toUpperCase()}`];
  })
}
</script>
<template>
  <div class="main container">
    <router-view />
  </div>
</template>

<style scoped>
.main {
  max-width: 450px;
}
</style>